<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>  
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
	<div>
		并发：
		<select id="concurrent">
			<option value="5" selected>5</option>
			<option value="10">10</option>
			<option value="10">15</option>
			<option value="10">20</option>
			<option value="10">30</option>
		</select>
		<!-- <input type="text" name="concurrent" id="concurrent" />  -->
		请求数：<input type="text" name="sum" id="sum" value="10" />
		接口：
		<select id="interName">
			<c:forEach items="${list}" var="item" varStatus="status">  
			  <option value="${item.val}">${item.name}</option>  
			</c:forEach> 
		</select>
		<input type="button" id="sub" value="测试" /><br/>
		<textarea  cols="50" rows="10" id="content"></textarea>
		<input type="button" id="exec" value="生成报告" />
	</div>
<script>
	$(function(){
		$('#exec').click(function(){
			window.location.href="downLoad.json?context="+$('#content').text()+"&name="+$('#interName').val();
		});
		$('#sub').click(function(){
			if(undefined==$('#concurrent').val()||''==$('#concurrent').val()
					||undefined==$('#sum').val()||''==$('#sum').val()
					||undefined==$('#interName').val()||''==$('#interName').val())
			{
				alert('请完善')
				return false;
			}
			$.ajax({
                type: "POST",
                url: "test.json",
                data: {
                	concurrent:$('#concurrent').val(),
                	sum:$('#sum').val(),
                	interName:$('#interName').val()
                },
                timeout: 1800000,  //30分钟的超时时间
                async: false,
                success: function(opResult){
                	$('#content').text(opResult.result);
                },
                error:function (XMLHttpRequest, textStatus, errorThrown) {
                	/*alert(XMLHttpRequest.status);
                	alert(XMLHttpRequest.readyState);
                	alert(textStatus);
                	alert('操作失败');*/
                }
            });
		})
	})
</script>
</body>
</html>